package search

import (
	"context"
	protos "goim-pro/api/protos/salty"
	. "goim-pro/examples/salty/helper"
	"goim-pro/pkg/utils"
	"log"
)

func Search(t protos.SearchServiceClient, searchType protos.SearchType, searchContent string) {
	searchReq := &protos.SearchReq{
		SearchType:    searchType,
		SearchContent: searchContent,
	}
	anyData, _ := utils.MarshalMessageToAny(searchReq)
	grpcReq := &protos.GrpcReq{
		UserId:   GetUserA().UserId,
		DeviceId: "LOCAL_DEV",
		Version:  "1",
		Language: 0,
		Os:       0,
		Token:    GetUserA().Token,
		Data:     anyData,
	}
	tr, err := t.Search(context.Background(), grpcReq)
	if err != nil {
		log.Fatalf("could not greet: %v", err.Error())
	}
	PrintResp(tr, &protos.SearchResp{})
}
